package com.capricornus.demo.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class WebSecurityConfig implements WebMvcConfigurer{
    private static final Logger logger = LoggerFactory.getLogger(WebSecurityConfig.class);


    @Override
    public void addCorsMappings(CorsRegistry registry) {
        // 允许跨域请求
        registry.addMapping("/**")//
                .allowedMethods("*")//
                .allowedOrigins("*")//
                .allowedHeaders("*")//
                .allowCredentials(true)//
                .maxAge(3600)//
        ;
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
    }
}
